// 
// Decompiled by Procyon v0.5.36
// 

package com.cyberfend.cyfsecurity;

import java.util.*;
import android.app.*;
import com.cyberfend.cyfsecurity.b.*;
import android.hardware.*;
import android.os.*;

final class o extends java.util.Observable implements android.hardware.SensorEventListener
{
    android.hardware.SensorManager a;
    android.hardware.Sensor b;
    android.hardware.Sensor c;
    android.hardware.Sensor d;
    boolean e;
    boolean f;
    boolean g;
    private boolean j;
    private boolean k;
    boolean h;
    long i;
    private float[] l;
    private float[] m;
    
    o(final android.app.Application application) {
        this.e = false;
        this.f = false;
        this.g = false;
        this.j = false;
        this.k = false;
        this.h = false;
        this.i = 0L;
        this.l = new float[3];
        this.m = new float[3];
        try {
            this.a = (android.hardware.SensorManager)application.getSystemService("sensor");
        }
        catch (java.lang.NullPointerException ex) {
            com.cyberfend.cyfsecurity.b.a.c("OrientationListener", "Exception on getting sensor service", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
    
    public final void a() throws java.lang.Exception {
        if (this.f) {
            this.a.unregisterListener((android.hardware.SensorEventListener)this, this.c);
            this.f = false;
        }
        if (this.g) {
            this.a.unregisterListener((android.hardware.SensorEventListener)this, this.d);
            this.g = false;
        }
        if (this.e) {
            this.a.unregisterListener((android.hardware.SensorEventListener)this, this.b);
            this.e = false;
        }
        this.h = false;
    }
    
    public final void onAccuracyChanged(final android.hardware.Sensor sensor, final int accuracy) {
    }
    
    public final void onSensorChanged(final android.hardware.SensorEvent event) {
        try {
            final long uptimeMillis = android.os.SystemClock.uptimeMillis();
            if (!this.h && event.accuracy == 0) {
                com.cyberfend.cyfsecurity.b.a.b("OrientationListener", "Unreliable orientation sensor data...", new java.lang.Throwable[0]);
                this.h = true;
            }
            final int type = event.sensor.getType();
            new java.lang.StringBuilder("Orientation sensor changed elapsed time: ").append(uptimeMillis - this.i).append(", Sensor Type: ").append(type);
            if (type == 9) {
                this.l = event.values.clone();
                this.j = true;
            }
            else if (type == 1) {
                this.l = event.values.clone();
                this.j = true;
            }
            else if (type == 2) {
                this.m = event.values.clone();
                this.k = true;
            }
            if (this.j && this.k) {
                new java.lang.StringBuilder("OrientationListener.onSensorChanged ").append(event.timestamp);
                if (uptimeMillis - this.i >= 100L || com.cyberfend.cyfsecurity.d.m == 1) {
                    new java.lang.StringBuilder("Orientation event elapsed time: ").append(uptimeMillis - this.i);
                    final boolean b = com.cyberfend.cyfsecurity.d.m != 0;
                    com.cyberfend.cyfsecurity.d.m = 0;
                    this.i = uptimeMillis;
                    this.setChanged();
                    this.notifyObservers(new com.cyberfend.cyfsecurity.n(this.l, this.m, this.i, b ? 2 : 1));
                    this.j = false;
                    this.k = false;
                }
            }
        }
        catch (java.lang.Exception ex) {
            com.cyberfend.cyfsecurity.b.a.b("OrientationListener", "Exception in processing orientation event", ex);
            com.cyberfend.cyfsecurity.f.a(ex);
        }
    }
}
